package com.simple.mqtt;

import com.simple.mqtt.server.core.MqttBroker;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * 简单MQTT代理应用
 * MQTT代理服务器主入口
 */
@SpringBootApplication
public class SimpleMqttApplication {

    /**
     * 应用入口
     * @param args 命令行参数
     */
    public static void main(String[] args) {
        // 启动Spring Boot应用
        SpringApplication.run(SimpleMqttApplication.class, args);
        
        // 配置并启动MQTT代理
        int core = Runtime.getRuntime().availableProcessors();
        MqttBroker broker = MqttBroker.builder()
                .host("127.0.0.1")
                .port(1883)
                .bossThreads(1)
                .workerThreads(core / 2)
                .businessThreads(core)
                .keepAliveTimeout(120000)
                .maxBytesInMessage(10 * 1024 * 1024)
                .maxClientIdLength(64)
                .usernamePassword("admin", "123456")
                .start();
    }

}
